<?php

if(@$_GET['languageAbbre']){
		
	$currentAbbre = $_GET['languageAbbre'];
	
	$newGroupID = "";
	
	$sqlCreateNewGroup = "INSERT INTO ".$PROJECT_DB_TABLES["groups"]."(g_name,g_created,g_priviledges,g_homepage,g_can_lock,g_can_approve) VALUES ('".$currentAbbre."','".getFullDate()."','2,3','xmlsiteeditor',0,0)";
	
	executeSQLQuery($sqlCreateNewGroup);
		
	$arrGroups = getRecord("SELECT g_id FROM ".$PROJECT_DB_TABLES["groups"]." WHERE g_name='".$currentAbbre."'");
	
	$newGroupID  = $arrGroups[0]["g_id"];
	
	$arrSelect = getRecord("SELECT g_priviledges FROM ".$PROJECT_DB_TABLES["groups"]." WHERE g_name='Developers'");
	
	$valuePriviledge = $arrSelect[0]["g_priviledges"].",".$arrGroups[0]["g_id"];
	
	if($USER -> getGroup() == "3"){
	
		$_SESSION[$PROJECT_CODE . "editable_groups"] = explode(",",$arrSelect[0]["g_priviledges"].",".$arrGroups[0]["g_id"]);
	}
	
	executeSQLQuery("UPDATE ".$PROJECT_DB_TABLES["groups"]." SET g_priviledges='".$valuePriviledge."' WHERE g_name = 'Developers'" );
	
	$sqlCloneTag = "";
	
	if($newGroupID != ""){

		$sqlCloneTag = "INSERT INTO ".$PROJECT_DB_TABLES["tags"]."(x_id,x_module,x_name,x_parent,x_accesstype,x_access,x_created,x_modified,x_statustype,x_status,x_section,x_sort,x_content,x_language,x_path,x_siteparent,x_sitesort) select CONCAT('".$currentAbbre."','(', x_section, x_path,')'),x_module,x_name,REPLACE(x_parent,CONCAT('en','('),CONCAT('".$currentAbbre."','(')),x_accesstype,CONCAT(x_access,',','".$newGroupID."'),x_created,x_modified,x_statustype,1,x_section,x_sort,x_content,'".$currentAbbre."',x_path,REPLACE(x_siteparent,CONCAT('en','('),CONCAT('".$currentAbbre."','(')),x_sitesort FROM ".$PROJECT_DB_TABLES["tags"]." WHERE x_language = 'en'";
	}
	
	if(executeSQLQuery($sqlCloneTag)){
		
		$sqlCloneAtrri = "INSERT INTO ".$PROJECT_DB_TABLES["atri"]."(at_id,at_xml_id,at_name,at_value,at_section,at_language,at_module) select REPLACE(at_id,CONCAT('en','('),CONCAT('".$currentAbbre."','(')),REPLACE(at_xml_id,CONCAT('en','('),CONCAT('".$currentAbbre."','(')),at_name,at_value,at_section,'".$currentAbbre."',at_module FROM ".$PROJECT_DB_TABLES["atri"]." WHERE at_language = 'en'";
	
		if(executeSQLQuery($sqlCloneAtrri)){
			
			addContent("True");
		}
	}
	
	
}

?>